package cn.java.basic;

class JStudentImpl implements JWork
{
    @Override
    public void work()
    {
        System.out.println("我是学生，我的工作是学习");
    }
}

class JTeacherImpl implements JWork
{
    @Override
    public void work()
    {
        System.out.println("我是教师，我的工作是教书");
    }
}

class JFarmerImpl implements JWork
{
    @Override
    public void work()
    {
        System.out.println("我是现代农民，我的工作是科学种田");
    }
}

class JWorkerImpl implements JWork
{
    @Override
    public void work()
    {
        System.out.println("我是工人，我的工作是在工厂进行生产");
    }
}

class JBussinessmanImpl implements JWork
{
    @Override
    public void work()
    {
        System.out.println("我是商人，我的工作是和全世界做生意");
    }
}

public class JPolyImpl
{
    public static void main(String[] args)
    {
        JWork worker=new JStudentImpl();
        worker.work();
        worker=new JTeacherImpl();  //向上转型
        worker.work();
        worker=new JFarmerImpl();
        worker.work();
        worker=new JWorkerImpl();
        worker.work();
        worker=new JBussinessmanImpl();
        worker.work();
    }
}
